Skip to content

Conversation

ghazwarhili
Copy link
Contributor

No description provided.

@ghazwarhili ghazwarhili changed the title asynch export draft version asynch export network Sep 18, 2025
import { RestoreNodesDialog } from './dialogs/restore-node-dialog';
import { CopyType } from './network-modification.type';
import { NodeSequenceType, NotificationType, PENDING_MODIFICATION_NOTIFICATION_TYPES } from 'types/notification-types';
import useExportSubscription from '../hooks/use-export-subscription.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import useExportSubscription from '../hooks/use-export-subscription.js';
import useExportSubscription from '../hooks/use-export-subscription';

sendAlert(eventData);
return; // here, we do not want to update the redux state
}
if (isExportNetworkNotification(eventData)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sylvain has a ticket in this sprint to remove studyUpdated to redux.
In the future, each callback handler must subscribe separately by useNotificationListener and inside each handler we check the updateType, for example in yours case, using predicate isExportNetworkNotification

}
}

export default function useExportNotificationHandler() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export default function useExportNotificationHandler() {
export default function useExportNotification() {

[userId, snackWarning, downloadExportNetworkFile, snackInfo, intl]
);

return { handleExportNotification };
Copy link
Contributor

@thangqp thangqp Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return { handleExportNotification };
useNotificationsListener(NotificationsUrlKeys.STUDY, { listenerCallbackMessage: handleExportNotification });

Comment on lines +62 to +71
const {
studyUuid,
node,
rootNetworkUuid,
format,
userId: useId,
exportUuid,
fileName,
error,
} = eventData.headers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const {
studyUuid,
node,
rootNetworkUuid,
format,
userId: useId,
exportUuid,
fileName,
error,
} = eventData.headers;
const eventData = JSON.parse(event.data);
if (isExportNetworkNotification(eventData)) {
const {
studyUuid,
node,
rootNetworkUuid,
format,
userId: useId,
exportUuid,
fileName,
error,
} = eventData.headers;
// old code
}

[dispatch, displayErrorNotifications, handleExportNotification, sendAlert]
);

useNotificationsListener(NotificationsUrlKeys.STUDY, { listenerCallbackMessage: handleStudyUpdate });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useExportNotification();

const userId = useSelector((state: AppState) => state.user?.profile.sub);

const handleExportNotification = useCallback(
(eventData: ExportNetworkEventData) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(eventData: ExportNetworkEventData) => {
(event: MessageEvent<string>) => {


const { subscribeExport } = useExportSubscription({
studyUuid: studyUuid,
nodeUuid: currentNode?.id,
Copy link
Contributor

@thangqp thangqp Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must pass nodeUuid in the params of subscribeExport because it is activeNode.id not currentNode.id

BUG when a node is not selected but we do export on this node via context menu

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three files use-export-xxx can be grouped in a file unique which presents a feature or move all into a directory, for example ./use-export-network

Copy link
Contributor

@thangqp thangqp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have create a PR which corrige following my comments except grouping hook files

#3345

Copy link

sonarqubecloud bot commented Oct 2, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
15.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants